/* AI服务配置页面 - 现代化设计风格 */

.new-ai-service-page {
  padding: 24px;
  background: linear-gradient(135deg, #f5f2e8 0%, #e8dcc0 100%);
  width: 100%;
  min-height: 100vh;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  position: relative;
}

/* 添加背景装饰 */
.new-ai-service-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(218, 165, 32, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

/* 加载状态 */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  color: #6c757d;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(108, 117, 125, 0.3);
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.service-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  gap: 24px;
  min-height: calc(85vh - 48px); /* 减去外层padding */
  align-items: stretch; /* 让所有列的高度保持一致 */
  /* 现代化背景板样式 */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.05);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 1;
}

/* 左侧：服务提供商面板 */
.providers-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* 移除固定高度，让它自然决定整体高度 */
}

.panel-header {
  padding: 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.panel-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

.panel-header p {
  font-size: 14px;
  color: #6c757d;
  margin: 0;
}

.providers-list {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 200px); /* 限制最大高度 */
}

/* 隐藏滚动条但保持滚动功能 */
.providers-list::-webkit-scrollbar {
  width: 6px;
}

.providers-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.providers-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.providers-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.provider-card {
  display: flex;
  align-items: center;
  padding: 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.provider-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s;
}

.provider-card:hover {
  background: linear-gradient(135deg, #ffffff 0%, #e9ecef 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.provider-card:hover::before {
  left: 100%;
}

.provider-card.active {
  background: linear-gradient(135deg, #ffffff 0%, #f0f8ff 100%);
  border-color: #007bff;
  box-shadow:
    0 8px 25px rgba(0, 123, 255, 0.2),
    0 0 0 1px rgba(0, 123, 255, 0.1);
  transform: translateY(-1px);
}

.provider-icon {
  font-size: 24px;
  margin-right: 12px;
  width: 32px;
  text-align: center;
}

.provider-info {
  flex: 1;
}

.provider-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.provider-info p {
  font-size: 12px;
  color: #6c757d;
  margin: 0;
}

.provider-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.provider-status.configured {
  background: #d4edda;
  color: #155724;
}

.provider-status.unconfigured {
  background: #f8d7da;
  color: #721c24;
}

/* 中间：配置内容 */
.config-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
  /* 直接在白色背景板中显示，无需额外背景 */
}

.config-header {
  margin-bottom: 32px;
  text-align: center;
}

.config-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.config-header p {
  font-size: 16px;
  color: #6c757d;
  margin: 0;
}

.config-form {
  width: 88%;
  max-width: none;
  margin: 0;
  padding: 0 20px;
}

.form-group {
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.required {
  color: #dc3545;
  margin-left: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-size: 15px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  box-sizing: border-box;
  position: relative;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow:
    0 0 0 3px rgba(0, 123, 255, 0.1),
    0 4px 12px rgba(0, 123, 255, 0.05);
  background: #ffffff;
  transform: translateY(-1px);
}

.form-group input:hover:not(:focus),
.form-group select:hover:not(:focus) {
  border-color: #ced4da;
  background: #ffffff;
}

.form-actions {
  display: flex;
  gap: 16px;
  margin-top: 40px;
  padding: 0 20px;
  justify-content: center;
}

.btn-primary,
.btn-secondary {
  min-width: 140px;
  padding: 16px 32px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 123, 255, 0.4);
}

.btn-primary:hover:not(:disabled)::before {
  left: 100%;
}

.btn-primary:disabled {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #6c757d;
  border: 1px solid #e9ecef;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  color: #495057;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.test-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.test-result.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.test-result.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* 右侧：流程面板 */
.process-panel {
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* 高度会自动与左侧面板保持一致 */
}

.process-panel h3 {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 24px;
}

.process-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.step.active {
  opacity: 1;
}

.step-number {
  width: 32px;
  height: 32px;
  background: #e9ecef;
  color: #6c757d;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.step.active .step-number {
  background: #007bff;
  color: white;
}

.step-content h4 {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.step-content p {
  font-size: 12px;
  color: #6c757d;
  margin: 0;
  line-height: 1.4;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .service-container {
    grid-template-columns: 1fr;
    gap: 16px;
    height: auto;
  }
  
  .providers-panel {
    order: 1;
  }
  
  .config-content {
    order: 2;
  }
  
  .process-panel {
    order: 3;
  }
  
  .providers-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
  }
  
  .process-steps {
    flex-direction: row;
    justify-content: space-between;
  }
  
  .step {
    flex-direction: column;
    text-align: center;
    flex: 1;
  }
}

@media (max-width: 768px) {
  .new-ai-service-page {
    padding: 16px;
  }
  
  .config-content {
    padding: 24px 16px;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .process-steps {
    flex-direction: column;
    gap: 16px;
  }
  
  .step {
    flex-direction: row;
    text-align: left;
  }
}
